package com.gitee.cashzhang27.test.boot.crypt.plus.util;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import java.time.LocalDateTime;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 实体父类
 *
 * @author Cash Zhang
 * @version v1.0
 * @since 2019/01/27 12:15
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class SuperEntity<T extends Model> extends Model<T> {

  private static final long serialVersionUID = -6198715768680716896L;

  /**
   * 字典ID
   */
  @TableId(type = IdType.UUID)
  private String id;
  /**
   * 删除标记(0-正常，1-删除)
   */
  @TableLogic
  @TableField(value = "is_deleted")
  private Integer deleted;
  /**
   * 创建人编码
   */
  @TableField(fill = FieldFill.INSERT)
  private String userCreate;
  /**
   * 创建时间
   */
  @TableField(fill = FieldFill.INSERT)
  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
  @JsonDeserialize(using = LocalDateTimeDeserializer.class)
  @JsonSerialize(using = LocalDateTimeSerializer.class)
  private LocalDateTime gmtCreate;
  /**
   * 修改人编码
   */
  @TableField(fill = FieldFill.UPDATE)
  private String userModified;
  /**
   * 修改时间
   */
  @TableField(fill = FieldFill.UPDATE)
  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
  @JsonDeserialize(using = LocalDateTimeDeserializer.class)
  @JsonSerialize(using = LocalDateTimeSerializer.class)
  private LocalDateTime gmtModified;
}
